package com.seanchenxi.gwt.xmlrpc.client.impl;

import com.google.gwt.http.client.URL;
import com.seanchenxi.gwt.xmlrpc.client.XmlRpcClientConfig;

/**
 * The Class XmlRpcClientConfigImpl.
 */
public class XmlRpcClientConfigImpl implements XmlRpcClientConfig{

	/** The url. */
	private String url;
	
	/** The username. */
	private String username;
	
	/** The password. */
	private String password;
	
	/** The timeout. */
	private int timeout = DEFAULT_TIMEOUT;

	/**
	 * Instantiates a new xml rpc client config impl.
	 *
	 * @param url the url
	 * @param username the username
	 * @param password the password
	 * @param timeout the timeout
	 */
	public XmlRpcClientConfigImpl(String url, String username, String password,
			int timeout) {
		this.url = URL.encode(url);
		this.username = username;
		this.password = password;
		this.timeout = timeout;
	}
	
	/**
	 * Instantiates a new xml rpc client config impl.
	 *
	 * @param url the url
	 * @param username the username
	 * @param password the password
	 */
	public XmlRpcClientConfigImpl(String url, String username, String password) {
		this(url,username, password, DEFAULT_TIMEOUT);
	}
	
	/**
	 * Instantiates a new xml rpc client config impl.
	 *
	 * @param url the url
	 */
	public XmlRpcClientConfigImpl(String url){
		this(url, null, null);
	}
	
	/**
	 * Sets the password.
	 *
	 * @param password the new password
	 */
	public void setPassword(String password) {
		this.password = password;
	}
	
	/**
	 * Sets the timeout.
	 *
	 * @param timeout the new timeout
	 */
	public void setTimeout(int timeout) {
		this.timeout = timeout;
	}
	
	/**
	 * Sets the url.
	 *
	 * @param url the new url
	 */
	public void setUrl(String url) {
		this.url = url;
	}
	
	/**
	 * Sets the username.
	 *
	 * @param username the new username
	 */
	public void setUsername(String username) {
		this.username = username;
	}
	
	/* (non-Javadoc)
	 * @see com.seanchenxi.gwt.xmlrpc.client.XmlRpcClientConfig#getPassword()
	 */
	@Override
	public String getPassword() {
		return password;
	}
	
	/* (non-Javadoc)
	 * @see com.seanchenxi.gwt.xmlrpc.client.XmlRpcClientConfig#getTimeout()
	 */
	@Override
	public int getTimeout() {
		return timeout;
	}
	
	/* (non-Javadoc)
	 * @see com.seanchenxi.gwt.xmlrpc.client.XmlRpcClientConfig#getUrl()
	 */
	@Override
	public String getUrl() {
		return url;
	}
	
	/* (non-Javadoc)
	 * @see com.seanchenxi.gwt.xmlrpc.client.XmlRpcClientConfig#getUsername()
	 */
	@Override
	public String getUsername() {
		return username;
	}
	
}
